<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.net.MulticastConduit</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.net.MulticastConduit");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791">tango.net.MulticastConduit</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Jun 2004 : Initial release<br><br>
<b>Version:</b><br>
Dec 2006 : South pacific version<br><br>
<b>author:</b><br>Kris<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L57">MulticastConduit</a></span>
<script>explorer.outline.addDecl('MulticastConduit');</script> : DatagramConduit;</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">MulticastConduit sends and receives data on a multicast group, as
        described by a class-D address. To send data, the recipient group
        should be handed to the write&#40;&#41; method. To receive, the socket is
        bound to an available local adapter/port as a listener and must
        join&#40;&#41; the group before it becomes eligible for input from there. </font><br><br>
<font color="black">While MulticastConduit is a flavour of datagram, it doesn't support
        being connected to a specific endpoint.<br><br>        Sending and receiving via a multicast group:
        <pre class="d_code">

        <span class="k">auto</span> <span class="i">group</span> = <span class="k">new</span> <span class="i">InternetAddress</span> (<span class="sl">"225.0.0.10"</span>, <span class="n">8080</span>);

        <span class="lc">// listen for datagrams on the group address (via port 8080)</span>
        <span class="k">auto</span> <span class="i">multi</span> = <span class="k">new</span> <span class="i">MulticastConduit</span> (<span class="i">group</span>);

        <span class="lc">// join and broadcast to the group</span>
        <span class="i">multi</span>.<span class="i">join</span>.<span class="i">write</span> (<span class="sl">"hello"</span>, <span class="i">group</span>);

        <span class="lc">// we are listening also ...</span>
        <span class="k">char</span>[<span class="n">8</span>] <span class="i">tmp</span>;
        <span class="k">auto</span> <span class="i">bytes</span> = <span class="i">multi</span>.<span class="i">read</span> (<span class="i">tmp</span>);
        
</pre><br><br>        Note that this example is expecting to receive its own broadcast;
        thus it may be necessary to enable loopback operation &#40;see below&#41;
        for successful receipt of the broadcast.<br><br>        Note that class D addresses range from 225.0.0.0 to 239.255.255.255<br><br>        </font><br><br>
<b>see:</b><br><br><br>
<b>http:</b><br>//www.kohala.com/start/mcast.api.txt<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L69">this</a></span>
<script>explorer.outline.addDecl('this');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Create a writable multicast socket</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L96">this</a></span>
<script>explorer.outline.addDecl('this');</script>(InternetAddress <span class="funcparam">group</span>, bool <span class="funcparam">reuse</span> = false);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Create a read/write multicast socket</font><br><br>
<font color="black">This flavour is necessary only for a multicast receiver
                &#40;e.g. use this ctor in conjunction with SocketListener&#41;.<br><br>                You should specify both a group address and a port to 
                listen upon. The resultant socket will be bound to the
                specified port &#40;locally&#41;, and listening on the class-D
                address. Expect this to fail without a network adapter
                present, as bind&#40;&#41; will not find anything to work with.<br><br>                The reuse parameter dictates how to behave when the port
                is already in use. Default behaviour is to throw an IO
                exception, and the alternate is to force usage.
                
                To become eligible for incoming group datagrams, you must
                also invoke the join&#40;&#41; method<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>MulticastConduit <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L111">loopback</a></span>
<script>explorer.outline.addDecl('loopback');</script>(bool <span class="funcparam">yes</span> = true);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Enable/disable the receipt of multicast packets sent
                from the same adapter. The default state is OS specific</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>MulticastConduit <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L133">ttl</a></span>
<script>explorer.outline.addDecl('ttl');</script>(uint <span class="funcparam">value</span> = Subnet);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the number of hops &#40;time to live&#41; of this socket. 
                Convenient values are
                <pre class="d_code">

                <span class="i">Host</span>:           <span class="i">packets</span> <span class="i">are</span> <span class="i">restricted</span> <span class="i">to</span> <span class="i">the</span> <span class="i">same</span> <span class="i">host</span>
                <span class="i">Subnet</span>:         <span class="i">packets</span> <span class="i">are</span> <span class="i">restricted</span> <span class="i">to</span> <span class="i">the</span> <span class="i">same</span> <span class="i">subnet</span>
                <span class="i">Site</span>:           <span class="i">packets</span> <span class="i">are</span> <span class="i">restricted</span> <span class="i">to</span> <span class="i">the</span> <span class="i">same</span> <span class="i">site</span>
                <span class="i">Region</span>:         <span class="i">packets</span> <span class="i">are</span> <span class="i">restricted</span> <span class="i">to</span> <span class="i">the</span> <span class="i">same</span> <span class="i">region</span>
                <span class="i">Continent</span>:      <span class="i">packets</span> <span class="i">are</span> <span class="i">restricted</span> <span class="i">to</span> <span class="i">the</span> <span class="i">same</span> <span class="i">continent</span>
                <span class="i">Unrestricted</span>:   <span class="i">packets</span> <span class="i">are</span> <span class="i">unrestricted</span> <span class="k">in</span> <span class="k">scope</span>
                
</pre></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>MulticastConduit <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L146">join</a></span>
<script>explorer.outline.addDecl('join');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add this socket to the listening group </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>MulticastConduit <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/MulticastConduit.d?rev=3791#L158">leave</a></span>
<script>explorer.outline.addDecl('leave');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove this socket from the listening group</font><br><br></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2004 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sat Aug  2 16:08:35 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>